package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.erp.bean.DanjuBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_danju_dingdan.view.*

/**
 * Created by Administrator on 2017/2/11/011.
 * 作者：刘洋
 */
class DanjuDingdanAdapter(private val mcontext: Context, private val mlist: List<DanjuBean.OnumsBean>) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)

    override fun getCount(): Int {
        return mlist.size
    }

    override fun getItem(position: Int): DanjuBean.OnumsBean {
        return mlist[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
        var v : View
        val vh: ViewHolder
        if (convertView == null) {
            v = minflater.inflate(R.layout.lv_danju_dingdan, null)
            vh = ViewHolder(v)
            v.tag = vh
        } else {
            v = convertView
            vh = convertView.tag as ViewHolder
        }
        val onumsBean = mlist[position]
        Myutil.settv(onumsBean.shop_name, vh.tvShopName)
        Myutil.settv(onumsBean.onum, vh.tvOnum)
        return v
    }

    class ViewHolder(v: View) {
        var tvShopName: TextView = v.tv_shop_name
        var tvOnum: TextView = v.tv_onum
    }
}
